<?php

include '../../db.php';
$connect = pg_connect($connectionString);
if (!$connect) {
    echo "connect : A connection to the server could not be established!";
    return false;
}

//$queryString = "SELECT id, move_date,type,price,quantity,total,product_id FROM warehouse_move order by move_date desc LIMIT 10 OFFSET " . ($_GET["pag"]*10);
$queryString = "
SELECT 
  warehouse_move.move_date, 
  warehouse_move.type, 
  warehouse_move.price, 
  warehouse_move.stock , 
  warehouse_move.total, 
  warehouse_move.quantity, 
  warehouse_product.fullname as product_id
FROM 
  public.warehouse_move, 
  public.warehouse_product
WHERE 
  warehouse_move.product_id = warehouse_product.id
ORDER BY move_date DESC LIMIT 10 OFFSET " . ($_GET["pag"]*10);

$query = pg_query($connect, $queryString);
if (!$query) {
    echo 'query : ';
    return false;
}
$arrRegistros = pg_fetch_all($query);
echo json_encode($arrRegistros);
$num_fields = pg_num_fields($query);
$num_rows = pg_num_rows($query);

pg_close($connect);
